package com.hoperun.test.controller;

import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author zhaolei
 * @date 2021/2/25 - 0:33
 */
@RestController
public class ParameterController {
    //请求映射信息
    @GetMapping("/car/{id}/owner/{username}")
    public Map<String, Object> getCar(@PathVariable("id") Integer id,
                                      @PathVariable("username") String name,
                                      //不带key值表示拿到所有的数据，带key表示只拿其中的某一个值
                                      @PathVariable Map<String, String> pv,
                                      @RequestHeader("User-Agent") String userAgent,
                                      @RequestHeader Map<String, String> header,
                                      @RequestParam("age") Integer age,
                                      @RequestParam("inter") List<String> inter,
                                      @RequestParam Map<String, String> param){
        Map<String, Object> map = new HashMap<>();
//        map.put("id", id);
//        map.put("name", name);
//        map.put("pv", pv);
//        map.put("UserAgent", userAgent);
//        map.put("header", header);
        map.put("age", age);
        map.put("inter", inter);
        map.put("param", param);
        return map;
    }

    @PostMapping("/user1")
    public Map<String, Object> postTest(@RequestBody String content){
        Map<String, Object> map = new HashMap<>();
        map.put("content", content);
        return map;
    }
}
